/*
 * SemanticAnalyzer.h
 *
 *  Created on: 14 июн. 2022 г.
 *      Author: nikitas
 */

#ifndef SRC_STATIC_CLASSES_SEMANTICANALYZER_SEMANTICANALYZER_H_
#define SRC_STATIC_CLASSES_SEMANTICANALYZER_SEMANTICANALYZER_H_

#include "../../Typedefs.h"
#include "../../Enums.h"
#include "../../Technical/RuntimeErrorClass.h"
#include "../../Technical/Logger.h"
#include "../../Technical/Config.h"
#include "../Arguments.h"

namespace STC_calc
{
/*
*	The SemanticAnalyzer class gets arguments from console
*	and transform it to configs and MathFunction
*/
class SemanticAnalyzer
{
private:
    static const std::map<std::string, std::pair<std::function<void(string_vector)>, size_t>> params_map;
	SemanticAnalyzer();
	~SemanticAnalyzer();
	static string_list make_main_parameters_safe(const int argc, char* argv[]);
	static string_list clop_parameters(const string_list& arguments);
    static string_list analyze_component(string_list arguments);
	static void cyclic_analyze(const string_list& arguments);
    std::pair<std::string, string_list> cut_subfunction(const std::string open_bracket, const string_list &args);
	static std::string comma_fix(const std::string& str) noexcept;

    static std::string careful_remove_spaces(std::string func);
    static bool is_short_params(const std::string& arg);
    static string_list make_simple_params(const std::string& arg, string_list arguments);
    static bool is_long_param(const std::string& arg);
    static string_list make_param(const std::string& arg, string_list arguments);
public:

	static std::pair<std::string, string_list> define_subfunction(const string_list& args);
	static bool can_convert(const std::string& str) noexcept;
	static void check_convert(std::string& str);
	static std::pair<std::string, bool> try_convert(const std::string& str) noexcept;
	static ldouble_vector convert(const string_vector& args);

	static std::shared_ptr<CurrentOptions> make_analysis(const int argc, char* argv[]);
};

} /* namespace STC_calc */

#endif /* SRC_STATIC_CLASSES_SEMANTICANALYZER_SEMANTICANALYZER_H_ */
